Welcome in this video.
It's going to be a really simple practice activity.
So I'd like for you to create a script that changes the colors of a bunch of parts that are part of
a disco four So you can create like a disco four effect.
I want you to change the colors every 2 seconds, and the colors can be whatever you want.
Just make them random each time.
Just note that you have to use the get children function in order to grab all the children of an instance.
In this case, I have provided a model and it's full of a bunch of parts, so you'll have to use the
get children function on the disco floor in order to grab all the parts.
So please spend one or 2 minutes to create a script to change the color of the parts, and I'll show
you my solution next.
So the first thing I want to do is get a reference to the model that is holding all the parts for the
disco floor.
So I'll just create a variable called for.
And then I'll do script parent.
And now I have my reference.
The next thing I want to do is to create a new random data type.
So that way I can generate random numbers to make random colors for my parts.
The next thing I want to do is create a while loop that runs forever.
And inside my while loop I'll create a for loop to loop through all the parts that are a part of my
disco four so I can change the color for every single one of them.
And then I'll pass my four model and I'll usually get children function to grab all the children of
the four.
Now this part is important.
I need to check whether or not the child I'm grabbing from my floor is a bass part.
Because since my script is in here, if I loop through here, one of these objects is inevitably going
to be the script and I can't change the color of the script.
So that's why we have this if statement here to check whether or not the item we are looking at is a
bass part.
If it is, then we can change the colour of a part to a new colour.
Three value.
From rugby and then we'll pass the rag object and use the next integer function and pass a number from
0 to 255.
And then I'll just copy this and paste it two more times.
So now we get a random color.
Last thing I need to make sure I do is yield the script for 2 seconds.
So that way my game doesn't crash.
And that way the four only changes colors every 2 seconds.
Now I should be able to run my game and see my disco for change colors.
Perfect.
We have our nice, cool little disco for.